<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>sipML5: Instant messaging (SMS-like)</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />

<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  <td id="projectlogo"><img alt="Logo" src="sipml-45x51.png"/></td>
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">sipML5
   &#160;<span id="projectnumber">1.0</span>
   </div>
   <div id="projectbrief">World&#39;s first HTML5 SIP Client</div>
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.8.0 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li class="current"><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Variables</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

</div>
<div class="header">
  <div class="headertitle">
<div class="title">Instant messaging (SMS-like) </div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p>Before sending or receiving SMS messages (SIP <b>MESSAGE</b>) you have to create a SIP stack as explained in <a class="el" href="page_create_sip_stack.html">Create SIP Stack</a> section. <br/>
 To listen to the messaging events: </p>
<div class="fragment"><pre class="fragment">o_stack.on_event_message = <span class="keyword">function</span> (evt) {
    tsk_utils_log_info(evt.s_phrase);
    <span class="keywordflow">switch</span> (evt.e_message_type) {
        <span class="keywordflow">case</span> tsip_event_message_type_e.I_MESSAGE:
            {
                evt.get_session().accept();
                tsk_utils_log_info(<span class="stringliteral">&quot;Incoming message. content=%s from=%s&quot;</span>, evt.get_message().get_content_as_string(), evt.get_session().o_uri_from);
                <span class="keywordflow">break</span>;
            }
        <span class="keywordflow">case</span> tsip_event_message_type_e.AO_MESSAGE:
            {
                <span class="keywordflow">if</span> (evt.i_code &gt;= 200 &amp;&amp; evt.i_code &lt;= 299) {
                    tsk_utils_log_info(<span class="stringliteral">&quot;sent&quot;</span>);
                }
                <span class="keywordflow">else</span> <span class="keywordflow">if</span> (evt.i_code &gt;= 300) {
                    tsk_utils_log_info(<span class="stringliteral">&quot;not sent (%d)&quot;</span>, evt.i_code);
                }
                <span class="keywordflow">break</span>;
            }
    }
}
</pre></div><p>To send a message to <b>006</b>: </p>
<div class="fragment"><pre class="fragment"><span class="comment">// creates an IM session</span>
var o_session_im = <span class="keyword">new</span> tsip_session_message(o_stack,
        <a class="code" href="classtsip__session.html">tsip_session</a>.prototype.<a class="code" href="classtsip__session.html#a80b77bc8b2094ca9a496b94a6e2c2c14">SetToStr</a>(<span class="stringliteral">&quot;006&quot;</span>),
        <a class="code" href="classtsip__session.html">tsip_session</a>.prototype.<a class="code" href="classtsip__session.html#a827acf39b9d9cbb6a057e23af7b2c402">SetHeader</a>(<span class="stringliteral">&quot;What&quot;</span>, <span class="stringliteral">&quot;IM&quot;</span>));
<span class="comment">// sends a message</span>
o_session_im.send(<span class="keyword">new</span> String(<span class="stringliteral">&quot;Pêche à la moule&quot;</span>), <span class="stringliteral">&quot;text/plain; charset=utf8&quot;</span>);
</pre></div> </div></div><!-- contents -->


<hr class="footer"/><address class="footer"><small>
Generated on Wed May 16 2012 23:47:02 for sipML5 by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.0
</small></address>

</body>
</html>
